<template>

  <div>
    <van-nav-bar
      title="查询"
      left-text="返回"
      right-text="刷新"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
      <van-list
        v-model="loading"
        style="padding:0 10px"
        :finished="finished"
        finished-text="没有更多了"
      >
        <van-cell
          v-for="item in list"
          :key="item.id"
          @click="toEdit(item.id,item.replyStatus,item.type,item.status)"
          style="font-size: 15px;"
          class="box"
        >
          <van-row
            type="flex"
            justify="space-between"
            style="border-bottom: 1px solid #dcdfe6;margin-bottom: 10px;"
          >
            <van-col
              :span="18"
              style="color: #faad14;"
            >
              {{item.type}}
            </van-col>
            <van-col
              :span="6"
              style="text-align: end;"
            >
              No:{{item.id}}
            </van-col>
          </van-row>
          <van-row>
            类型:线上非授权销售投诉
          </van-row>
          <van-row>
            投诉内容:{{item.content}}
          </van-row>
          <van-row>
            时间:{{item.createTime}}
          </van-row>
          <van-row
            style="color:#66c2cf"
            v-if="item.replyContentNew"
          >
            最新回复:{{item.replyContentNew}}
          </van-row>
          <van-row
            style="color:#66c2cf"
            v-if="item.replyStatus"
          >
            受理状态:{{item.replyStatus}}
          </van-row>
          <van-row
            style="color:#66c2cf"
          >
            积分:{{item.integrate}}
          </van-row>
        </van-cell>

      </van-list>

  </div>
</template>
<script>
import { Notify } from 'vant'

export default {
  data() {
    return {
      list: [],
      active: '',
      typeList: ['咨询', '规章制度建议', '其他建议', '线上非授权销售投诉', '其他投诉', '举报'],
      loading: false,
      finished: false
    }
  },
  computed: {
    linkId() {
      return localStorage.getItem('linkId')
    }
  },
  created: function () {
    document.title = '查询'
    this.active = this.status
  },
  mounted() {
    this.onLoad()
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1)
    },
    onClickRight() {
      this.onLoad()
    },
    onChange() {
      this.status = this.active
      this.onLoad()
    },
    toEdit(num, replyStatus, type,status) {
        if (type == '线上非授权销售投诉') {
          this.$router.push({ path: 'tx', query: { id: num,replyStatus: replyStatus,status:status} })
        }
        else{
           this.$router.push({ path: 'form', query: { id: num } })
        }
      
    },
    onLoad() {
      this.loading = true
      const params = {
        linkId: this.linkId
      }
      try {
        this.$http({
          url: '/api/gateway/basemgt-feedback/feedback/getIntegrate',
          method: 'get',
          params: params
        }).then(data => {
          if (data.code == 200) {
            this.list = data.data
            this.list.map(item => {
              this.typeList.map((subitem, index) => {
                if (item.type == index + 1) {
                  item.type = subitem
                }
              })
            })
            this.list.sort((a, b) => b.id - a.id)
          } else {
            Notify({ type: 'warning', message: data.msg })
          }
        })
      } catch (error) {
      } finally {
        this.loading = false
        this.finished = true
      }
    }
  }
}
</script>
<style scoped>
.title {
  text-align: center;
  padding: 10px;
  font-size: 18px;
  background: #d9d9d9;
  font-weight: 500;
}
.box {
  box-shadow: 0px 15px 30px -5px rgb(150 150 150 / 30%);
  margin-bottom: 10px;
  border-radius: 10px;
}
</style>
<style>
.van-tab--active {
  font-weight: 500;
  border-radius: 10px;
  color: #1890ff;
  background: rgba(250, 235, 215, 0.44);
  /* border-bottom: 2px solid #1890ff; */
}
.van-tabs__line {
  background: transparent;
}
</style>